Skip to main content

ifnull

ifnull

Description

Syntax:

ifnull(expr1, expr2)

If the value of expr1 is not null, this function will return expr1; otherwise, it will return expr2.

Example

mysql> select ifnull(1,0);
+--------------+
| ifnull(1, 0) |
+--------------+
| 1 |
+--------------+

mysql> select ifnull(null,10);
+------------------+
| ifnull(NULL, 10) |
+------------------+
| 10 |
+------------------+

Keywords

IFNULL